/**
 * The Command class is a to be extended class for creating executable command objects
 * @author zulianp@lu.unisi.ch & remo.lemma@lu.unisi.ch
 * @version 0.1
 */



package ch.unisi.inf.projects.java.uom.gui.commands;

import java.util.List;
import java.util.ArrayList;
import javax.swing.AbstractAction;

public abstract class Command extends AbstractAction{
	
	private List<CommandListener> listeners;
	
	public Command ()
	{
		listeners = new ArrayList<CommandListener>();
	}
	
	public void addCommandListener (final CommandListener li)
	{
		listeners.add(li);
	}
	
	public void removeCommandListener (final CommandListener li)
	{
		listeners.remove(li);
	}
	
	protected void fireActionPerformed()
	{
		for (final CommandListener li : listeners)
			li.ActionPerformed(this);
	}
	
	public void setNameAndDesc (final String name, final String description)
	{
		this.putValue(NAME, name);
		this.putValue(SHORT_DESCRIPTION, description);
	}

}